using System;
using System.Collections;

using LocalBoard.Domain;
using LocalBoard.Persistence;

namespace LocalBoard.Controller
{
	/// <summary>
	/// Summary description for PollMessageController.
	/// </summary>
	public class PollMessageController : MessageController
	{
		public PollMessageController(int messageId, IAccessorFactory accessorFactory) : base(messageId, accessorFactory)
		{
		}
		public PollMessageController(PollMessage pollMessage, IAccessorFactory accessorFactory) : base(pollMessage, accessorFactory)
		{
		}
		public int AddPollItem(PollItem pollItem)
		{
			return _accessorFactory.GetPollItemAccessor().Insert(pollItem, _messageId);
		}

		public void DeletePollItem(int pollItemId)
		{
			_accessorFactory.GetPollItemAccessor().Delete(pollItemId, _messageId);
		}

		public void PostPoll(int profileId, int pollItemId)
		{
			_accessorFactory.GetPollItemAccessor().PostPoll(pollItemId, _messageId, profileId);
		}

		public bool DidUserVote(int profileId)
		{
			return _accessorFactory.GetPollItemAccessor().GetVoterIdListByMessageId(_messageId).Contains(profileId);
		}
	}
}
